package com.dzsw.javabase.binary;

import cn.hutool.core.util.HexUtil;

import java.nio.charset.StandardCharsets;

public class Utf8ToUtf16Sample {

    public static void main(String[] args) {
        String s = "ClientApp";
        byte[] b = s.getBytes(StandardCharsets.UTF_8);
        System.out.println("UTF-8 >> " + String.valueOf(HexUtil.encodeHex(b, false)));
        b = s.getBytes(StandardCharsets.UTF_16LE);
        System.out.println("UTF-16 小端序 >> " + String.valueOf(HexUtil.encodeHex(b, false)));
        b = s.getBytes(StandardCharsets.UTF_16BE);
        System.out.println("UTF-16 大端序 >> " + String.valueOf(HexUtil.encodeHex(b, false)));
    }
}
